/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * <p>Project: javase - Img5
 * <p>Powered by webrx On 2021-12-17 18:35:28
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Img5 {
    public static void main(String[] args) throws Exception {
        var i = new BufferedImage(300, 300, 2);
        var g = i.createGraphics();
        g.setColor(Color.RED);
        g.fillRect(0, 0, 300, 300);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);


        g.setColor(Color.YELLOW);
        g.drawLine(0, 150, 300, 150);
        int yy = 0;
        for (int i1 = 0; i1 < 300; i1++) {
            g.drawLine(150, yy, 150, yy += 5);
            yy += 5;

        }

        Polygon plygon = new Polygon();
        plygon.addPoint(0, 30);
        plygon.addPoint(30, 30);
        plygon.addPoint(30, 0);
        //g.fillPolygon(plygon);

        g.drawPolygon(plygon);


        g.setColor(new Color(0x00, 0x00, 0xff, 0x77));
        int x = 150;
        int y = 150;
        //g.fillRect(x, y, 50, 50);
        //g.drawRect(x, y, 50, 50);

        g.fillOval(x - 25, y - 25, 50, 50);

        g.dispose();
        ImageIO.write(i, "png", new File("c:/t.png"));
        Runtime.getRuntime().exec("cmd /k start c:/t.png");
    }
}
